<template>
    <div class="paddB60">
        <div class="operatBtnWrapper">
            <button class="operatBtn marR5" @click.stop="$router.push('/admin/notice/add')">新建公告</button>
		</div>

        <div class="marLR20 marT20">
            <el-row :gutter="40">
                <el-col :span="12">
                    <h3 class="setH3">通知类</h3>
                    
                    <div class="marB20">
                        <div style="display:inline-block;" class="marT10">
                            <el-input v-model.trim="keyword" class="inputTxtWrapper" placeholder="根据标题或文件编号搜索" maxlength='20'></el-input>
                        </div>
                        
                        <el-select v-model="noticeAudit" placeholder="请选择状态" class="inputTxtWrapper marR5 marT10">
                            <el-option
                            v-for="item of releaseStatusArr"
                            :key="item.releaseStatusNum"
                            :label="item.releaseStatusName"
                            :value="item.releaseStatusNum">
                            </el-option>
                        </el-select>
                        <button class="operatBtn marR5 marT10" @click.stop="handleChange">搜索</button>
                    </div>
                    
                    <!-- 通知类公告内容 -->
                    <div v-if = "noticeList.length > 0">
                        <dl v-for = "(item,index) of noticeList" :key = "item.id" :index = "index" class="marT20">
                            <dt class="noticeItemNav">
                                <el-row>
                                    <el-col :span="8">
                                        {{item.notice_title === null ? '/' : item.notice_title}}
                                    </el-col>
                                    <el-col :span="16" class="txtAlignR">
                                        <span title="修改" v-if = "item.is_draft === 2 && getLoginUserId == item.notice_release_user_id"><icon name="change" class="scaleIcon1" title="修改" @click.native.stop="routerToNoticeEdit(item.id)"></icon></span>

                                        <span title="置顶公告" class="marL15" v-show="item.is_roof_place === 1 && item.lastAuditStatusStr === '已发布'"><icon name="roof" class="scaleIcon3" @click.native.stop="roofNotice(item.id)" style="cursor:pointer;"></icon></span>
                                        <span title="取消置顶公告" class="marL15" v-show="item.is_roof_place !== 1 && item.lastAuditStatusStr === '已发布'"><icon name="noRoof" class="scaleIcon3" @click.native.stop="cancelRoofNotice(item.id)" style="cursor:pointer;"></icon></span>

                                        <span title="隐藏公告" class="marL15" v-show="item.is_notice_hide === 1"><icon name="show" class="scaleIcon1" style="cursor:pointer;" @click.native.stop="hideNotice(item.id)"></icon></span>
                                        <span title="显示公告" class="marL15" v-show="item.is_notice_hide === 2"><icon name="showDisabled" class="scaleIcon1" style="cursor:pointer;" @click.native.stop="ShowNotice(item.id)"></icon></span>

                                        <!-- 需要当前登录人员审核的条件，公告待审核，本人没有审核过该条公告，需要有审核权限 ，且不是草稿-->
                                        <span title="审核公告" class="marL15" v-if = "item.is_draft !== 2 && item.lastAuditStatusStr === '待审核' && item.youAwalysAuditNoticeCount === 0 && getRoles.indexOf(18) > -1 && item.unAuditUserStaffnum.split(',').indexOf(getStaffNum) > -1"><icon name="examine" class="scaleIcon1" @click.native.stop="examineNotice(item.id,item.notice_release_range)" style="cursor:pointer;"></icon></span>
                                    
                                        <span title="预览公告" class="marL15" v-if = "item.notice_file_path !== null"><icon name="view" class="scaleIcon1" @click.native.stop="viewNoticeFile(item.notice_file_path)" style="cursor:pointer;"></icon></span>
                                    </el-col>
                                </el-row>
                            </dt>
                            <dd>
                                <div class="otherInfo ellipsis" 
                                        :title="'文件编号:' + item.notice_file_num + ',发布时间:' + (item.lastAuditStatusStr === '已发布' ? item.lastNoticeAuditTime : '/') + ',新建人:' + item.noticeReleaseUserName + ', 状态:' + (item.is_draft === 2 ? '草稿' : item.lastAuditStatusStr)">
                                    文件编号:{{item.notice_file_num}},
                                    <el-popover
                                        placement="top-start"
                                        width="200"
                                        trigger="hover">
                                        <!-- 新建时间 -->
                                        <div>
                                            <p class="ellipsis" :title="item.notice_add_time">新建时间:{{item.notice_add_time}}</p>
                                        </div>
                                        <!-- 审核人(已审核) -->
                                        <div>
                                            <p class="ellipsis" :title="item.auditedUserNames === null ? '/' : item.auditedUserNames">审核人(已审核):{{item.auditedUserNames === null ? '/' : item.auditedUserNames}}</p>
                                        </div>
                                        <!-- 审核人(未审核) -->
                                        <div>
                                            <p class="ellipsis" :title="item.unAuditUserNames === null ? '/' : item.unAuditUserNames">审核人(未审核):{{item.unAuditUserNames === null ? '/' : item.unAuditUserNames}}</p>
                                        </div>
                                         <!-- 审核原因 -->
                                        <div>
                                            <p class="ellipsis" :title="item.noticeAuditReason === null ? '/' : item.noticeAuditReason">审核原因:{{item.noticeAuditReason === null ? '/' : item.noticeAuditReason}}</p>
                                        </div>
                                         <!-- 隐藏原因 -->
                                        <div>
                                            <p class="ellipsis" :title="item.notice_hide_reason === null ? '/' : item.notice_hide_reason">隐藏原因:{{item.notice_hide_reason === null ? '/' : item.notice_hide_reason}}</p>
                                        </div>
                                        <span slot="reference">详细信息,</span>
                                    </el-popover>
                                    <el-popover
                                        placement="top-start"
                                        width="300"
                                        v-model = "item.isPoperShow"
                                        trigger="manual">
                                        <!-- 发布范围 -->
                                        <div>
                                            <div  v-if = "item.notice_release_range === '2'">
                                                <p class="ellipsis" title="人员">人员:{{currUserNames.length === 0 ? '/' : ''}}</p>
                                                <p v-for="item of currUserNames" :key = "item" style="text-indent:2em;">{{item}}</p>
                                            </div>
                                            <div class="ellipsis" v-else>发布范围:全公司</div>
                                        </div>
                                        <span slot="reference">
                                            <span  @mouseenter.stop = "previewRange(item.id,item.notice_release_range,item.lastAuditStatusStr,index,'通知')"  @mouseleave.stop = "handleMouseOut(index,'通知')">发布范围,</span>
                                        </span>
                                    </el-popover>
                                    <template class="ellipsis" v-if = "item.lastAuditStatusStr === '已发布'">发布时间:{{item.lastNoticeAuditTime}},</template>
                                    <template class="ellipsis" v-else>发布时间:/,</template>
                                    新建人:{{item.noticeReleaseUserName}},
                                    状态:{{item.is_draft === 2 ? '草稿' : item.lastAuditStatusStr}}
                                </div>
                            </dd>
                        </dl>
                    </div>
                    <div v-else class="tipNoData">暂无数据</div>
                </el-col>
                

                <el-col :span="12">
                    <h3 class="setH3">制度类</h3>

                    <div class="marB20">
                        <div style="display:inline-block;" class="marT10">
                            <el-input v-model.trim="sysKeyWord" class="inputTxtWrapper" placeholder="根据标题或文件编号搜索" maxlength='20'></el-input>
                        </div>
                        
                        <el-select v-model="sysNoticeAudit" placeholder="请选择状态" class="inputTxtWrapper marR5 marT10">
                            <el-option
                            v-for="item of releaseStatusArr"
                            :key="item.releaseStatusNum"
                            :label="item.releaseStatusName"
                            :value="item.releaseStatusNum">
                            </el-option>
                        </el-select>
                        <button class="operatBtn marR5 marT10" @click.stop="sysHandleChange">搜索</button>
                    </div>

                    
                    <!-- 制度类公告内容 -->
                    <div v-if = "systemNoticeList.length > 0">
                        <dl v-for = "(item,index) of systemNoticeList" :key = "item.id" :index = "index" class="marT20">
                            <dt class="noticeItemNav">
                                <el-row>
                                    <el-col :span="8">
                                        {{item.notice_title === null ? '/' : item.notice_title}}
                                    </el-col>
                                    <el-col :span="16" class="txtAlignR">
                                        <span title="修改" v-if = "item.is_draft === 2 && getLoginUserId == item.notice_release_user_id"><icon name="change" class="scaleIcon1" title="修改" @click.native.stop="routerToNoticeEdit(item.id)"></icon></span>

                                        <span title="置顶公告" class="marL15" v-show="item.is_roof_place === 1 && item.lastAuditStatusStr === '已发布'"><icon name="roof" class="scaleIcon3" @click.native.stop="roofNotice(item.id)" style="cursor:pointer;"></icon></span>
                                        <span title="取消置顶公告" class="marL15" v-show="item.is_roof_place !== 1 && item.lastAuditStatusStr === '已发布'"><icon name="noRoof" class="scaleIcon3" @click.native.stop="cancelRoofNotice(item.id)" style="cursor:pointer;"></icon></span>

                                        <span title="隐藏公告" class="marL15" v-show="item.is_notice_hide === 1"><icon name="show" class="scaleIcon1" style="cursor:pointer;" @click.native.stop="hideNotice(item.id)"></icon></span>
                                        <span title="显示公告" class="marL15" v-show="item.is_notice_hide === 2"><icon name="showDisabled" class="scaleIcon1" style="cursor:pointer;" @click.native.stop="ShowNotice(item.id)"></icon></span>

                                        <!-- 需要当前登录人员审核的条件，公告待审核，本人没有审核过该条公告，需要有审核权限 -->
                                        <span title="审核公告" class="marL15" v-if = "item.is_draft !== 2 && item.lastAuditStatusStr === '待审核' && item.youAwalysAuditNoticeCount === 0 && getRoles.indexOf(18) > -1 && item.unAuditUserStaffnum.split(',').indexOf(getStaffNum) > -1"><icon name="examine" class="scaleIcon1" @click.native.stop="examineNotice(item.id,item.notice_release_range)" style="cursor:pointer;"></icon></span>
                                    
                                        <span title="预览公告" class="marL15" v-if = "item.notice_file_path !== null"><icon name="view" class="scaleIcon1" @click.native.stop="viewNoticeFile(item.notice_file_path)" style="cursor:pointer;"></icon></span>
                                    </el-col>
                                </el-row>
                            </dt>
                            <dd>
                                <p class="otherInfo ellipsis" 
                                    :title="'文件编号:' + item.notice_file_num + ',发布时间:' + (item.lastAuditStatusStr === '已发布' ? item.lastNoticeAuditTime : '/')  + ',新建人:' + item.noticeReleaseUserName + ',状态:' + (item.is_draft === 2 ? '草稿' : item.lastAuditStatusStr)">
                                    文件编号:{{item.notice_file_num}},
                                    <el-popover
                                        placement="top-start"
                                        width="200"
                                        trigger="hover">
                                        <!-- 新建时间 -->
                                        <div>
                                            <p class="ellipsis" :title="item.notice_add_time">新建时间:{{item.notice_add_time}}</p>
                                        </div>
                                        <!-- 审核人(已审核) -->
                                        <div>
                                            <p class="ellipsis" :title="item.auditedUserNames === null ? '/' : item.auditedUserNames">审核人(已审核):{{item.auditedUserNames === null ? '/' : item.auditedUserNames}}</p>
                                        </div>
                                        <!-- 审核人(未审核) -->
                                        <div>
                                            <p class="ellipsis" :title="item.unAuditUserNames === null ? '/' : item.unAuditUserNames">审核人(未审核):{{item.unAuditUserNames === null ? '/' : item.unAuditUserNames}}</p>
                                        </div>
                                        <span slot="reference">详细信息,</span>
                                         <!-- 审核原因 -->
                                        <div>
                                            <p class="ellipsis" :title="item.noticeAuditReason === null ? '/' : item.noticeAuditReason">审核原因:{{item.noticeAuditReason === null ? '/' : item.noticeAuditReason}}</p>
                                        </div>
                                         <!-- 隐藏原因 -->
                                        <div>
                                            <p class="ellipsis" :title="item.notice_hide_reason === null ? '/' : item.notice_hide_reason">隐藏原因:{{item.notice_hide_reason === null ? '/' : item.notice_hide_reason}}</p>
                                        </div>
                                    </el-popover>
                                    <el-popover
                                        placement="top-start"
                                        width="300"
                                        v-model = "item.isPoperShow"
                                        trigger="manual">
                                        <!-- 发布范围 -->
                                        <div>
                                            <div  v-if = "item.notice_release_range === '2'">
                                                <p class="ellipsis" title="人员">人员:{{currUserNames.length === 0 ? '/' : ''}}</p>
                                                <p v-for="item of currUserNames" :key = "item" style="text-indent:2em;">{{item}}</p>
                                            </div>
                                            <div class="ellipsis" v-else>发布范围:全公司</div>
                                        </div>
                                        <span slot="reference">
                                            <span  @mouseenter.stop = "previewRange(item.id,item.notice_release_range,item.lastAuditStatusStr,index,'制度')"  @mouseleave.stop = "handleMouseOut(index,'制度')">发布范围,</span>
                                        </span>
                                    </el-popover>
                                    <template v-if = "item.lastAuditStatusStr === '已发布'">发布时间:{{item.lastNoticeAuditTime}},</template>
                                    <template v-else>发布时间:/,</template>
                                    新建人:{{item.noticeReleaseUserName}},
                                    状态:{{item.is_draft === 2 ? '草稿' : item.lastAuditStatusStr}}
                                </p>
                            </dd>
                        </dl>
                    </div>
                    <div v-else class="tipNoData">暂无数据</div>

                </el-col>
            </el-row>
        </div>

         <!-- 通知类公告分页 -->
        <div class="leftPageWripper" v-if="noticeList.length > 0">
            <el-pagination
            @size-change="handleChange"
            @current-change="handleChange"
            :current-page.sync="serverPage.currPage"
            :page-sizes="[10, 20, 30, 40]"
            :page-size.sync="serverPage.pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="serverPage.totalSize">
            </el-pagination>
        </div>

        <!-- 制度类公告分页 -->
        <div class="rightPageWripper" v-if="systemNoticeList.length > 0">
            <el-pagination
            @size-change="sysHandleChange"
            @current-change="sysHandleChange"
            :current-page.sync="sysServerPage.currPage"
            :page-sizes="[10, 20, 30, 40]"
            :page-size.sync="sysServerPage.pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="sysServerPage.totalSize">
            </el-pagination>
        </div>
        
        <!-- 公告记录审核弹框 -->
        <el-dialog
            title="公告记录审核"
            :visible.sync="isDialogVisible"
            width="30%"
            :before-close="cancelExamineNotice"
            center>
            <el-radio-group v-model="noticeAuditStatus">
                <el-radio :label="2">通过</el-radio>
                <el-radio :label="3">不通过</el-radio>
            </el-radio-group>
            <el-input v-model.trim = "noticeAuditReason" placeholder="请输入审核原因" maxlength='255' class="inputTxtWrapper marT20"  v-show="noticeAuditStatus === 3"></el-input>
            <p class="tipRed" v-show="noticeAuditStatus === 3">审核不通过需要填写原因</p>
            <span slot="footer" class="dialog-footer">
                <el-button @click="cancelExamineNotice">取 消</el-button>
                <el-button type="primary" @click="sureExamineNotice">确 定</el-button>
            </span>
        </el-dialog>
        
        <!-- 填写隐藏原因弹框 -->
        <el-dialog
            title="隐藏原因"
            :visible.sync="isHideReasonDialogShow"
            width="30%"
            :before-close="cancelHideReason"
            center>
            <el-input v-model.trim = "noticeHideReason" placeholder="请填写隐藏原因" maxlength='255' class="inputTxtWrapper marT20"></el-input>
            <p class="tipRed">隐藏公告需要填写原因</p>
            <span slot="footer" class="dialog-footer">
                <el-button @click="cancelHideReason">取 消</el-button>
                <el-button type="primary" @click="sureHideNotice">确 定</el-button>
            </span>
        </el-dialog>

    </div>
</template>

<script>
import http from '@/assets/js/http'
import _g from '@/assets/js/global'

import { mapGetters } from 'vuex'

import { releaseStatusArr } from '@/assets/js/data.js'

export default {
  data() {
    return {
      releaseStatusArr,

      noticeList: [], //  通知类公告列表
      systemNoticeList: [], //  制度类公告列表

      isDialogVisible: false, //  审核弹框默认隐藏
      noticeAuditStatus: 2, //    审核结果，默认审核通过
      noticeAuditReason: '', // ..审核原因
      currNoticeId: null, //  当前待审核的公告id
      currUserNames: [], //   当前公告记录的发布人员范围
      noticeReleaseRange: null, //   当前发布范围

            //  通知类公告分页
      serverPage: {                                                                                              //  后台分页
        pageSize: 10,                 //  每页显示10个
        totalSize: 0,                 //  总记录数
        currPage: 1                    //  当前页码
      },
      keyword: '',    //  模糊搜索关键词
      noticeAudit: 0,    //  审核结果搜索

            //  制度类公告分页
            //  通知类公告分页
      sysServerPage: {                                                                                              //  后台分页
        pageSize: 10,                 //  每页显示10个
        totalSize: 0,                 //  总记录数
        currPage: 1                    //  当前页码
      },
      sysKeyWord: '',    //  模糊搜索关键词
      sysNoticeAudit: 0,    //  审核结果搜索

            // 隐藏原因
      noticeHideReason: '',
      isHideReasonDialogShow: false, //   填写隐藏原因弹框默认隐藏
      currHideNoticeId: null//  当前待隐藏的公告id
    }
  },
  created() {
    this.getAllPagingNotice()
  },
  computed: {
    ...mapGetters([                                                                         //  用户权限
      'getRoles', 'getLoginUserId', 'getStaffNum'
    ])
  },
  methods: {
    f() {
      var dom = document.getElementsByClassName('otherInfo')

      console.log(dom[0].innerText.length)
    },
        /* 鼠标悬浮展示公告发布范围 */
    previewRange(noticeId, noticeReleaseRange, lastAuditStatusStr, index, str) {
      const that = this

      const currUserNames = []

      if (noticeReleaseRange === '1') { //   如果发布范围为全公司
        if (str === '通知') {
          that.noticeList[index].isPoperShow = true
        } else if (str === '制度') {
            that.systemNoticeList[index].isPoperShow = true
          }
      } else if (noticeReleaseRange === '2') { // ..如果发布范围为组织架构
        let arr = []
        if (str === '通知') {
            arr = that.noticeList.filter(item => item.isPoperShow === true)
          } else if (str === '制度') {
              arr = that.systemNoticeList.filter(item => item.isPoperShow === true)
            }

        if (arr.length > 0) { //   确保每次只有一次请求，防止重复请求
            return
          }
                // 请求发布范围数据
        if (lastAuditStatusStr === '已发布' || lastAuditStatusStr === '审核不通过') {
            _g.showLoading('加载中')
            that.apiPost('admin/notice/queryNoticeReadOrganiNams', { noticeId }).then(res => {
                _g.showLoading().close()
                if (typeof res === 'string') {
                    res = JSON.parse(res)
                  }
                if (res.data.isSuccess === 0) {
                    for (const item of res.data.result.users) {
                      currUserNames.push(item.user_name)
                    }
                    that.currUserNames = currUserNames
                    if (str === '通知') {
                      that.noticeList[index].isPoperShow = true
                    } else if (str === '制度') {
                        that.systemNoticeList[index].isPoperShow = true
                      }
                  } else if (res.data.isSuccess === 1) {
                    _g.toastMsg('error', res.message)
                  }
              }).catch((error) => {})
          } else { //   如果公告未审核过
            _g.showLoading('加载中')
            that.apiPost('admin/notice/queryReleaseRangeByNoticeId', { noticeId }).then(res => {
                _g.showLoading().close()
                if (typeof res === 'string') {
                    res = JSON.parse(res)
                  }
                if (res.data.isSuccess === 0) {
                    for (const item of res.data.result.users) {
                      currUserNames.push(item.user_name)
                    }
                    that.currUserNames = currUserNames
                    if (str === '通知') {
                      that.noticeList[index].isPoperShow = true
                    } else if (str === '制度') {
                        that.systemNoticeList[index].isPoperShow = true
                      }
                  } else if (res.data.isSuccess === 1) {
                    _g.toastMsg('error', res.message)
                  }
              }).catch((error) => {})
          }
      }
    },
        /* 鼠标离开隐藏公告发布范围 */
    handleMouseOut(index, str) {
      this.currUserNames = []

      if (str === '通知') {
        this.noticeList[index].isPoperShow = false
      } else if (str === '制度') {
        this.systemNoticeList[index].isPoperShow = false
      }
    },
        /* 预览公告 */
        // routerToNoticeDetail(noticeId){
        //     this.$router.push({path:'/admin/notice/noticeDetail',query:{noticeId}})
        // },
        /* 跳转到编辑公告页面 */
    routerToNoticeEdit(noticeId) {
      this.$router.push({ path: '/admin/notice/edit', query: { noticeId }})
    },
        /* 查看公告附件 */
    viewNoticeFile(noticeFilePath) {
      window.open(noticeFilePath)
    },
        /* 通知类公告分页 */
    handleChange() {
      this.getAllPagingNotice(1)
    },
        /* 制度类公告分页 */
    sysHandleChange() {
      this.getAllPagingNotice(2)
    },
        /* 分页查询所有公告 */
    getAllPagingNotice(noticeType) {
      const that = this
      const noticeList = []
      const data = {}
      if (noticeType === undefined || noticeType === 1) { // 如果为初始或通知类
        data.pageSize = that.serverPage.pageSize
        data.currPage = that.serverPage.currPage
        data.keyword = that.keyword
        data.noticeAuditResult = that.noticeAudit
        data.noticeType = noticeType
      } else if (noticeType === 2) { //   如果为制度类
        data.pageSize = that.sysServerPage.pageSize
        data.currPage = that.sysServerPage.currPage
        data.keyword = that.sysKeyWord
        data.noticeAuditResult = that.sysNoticeAudit
        data.noticeType = noticeType
      }

      _g.showLoading('加载中')
      this.apiPost('admin/notice/getAllPagingNotice', data).then(res => {
        _g.showLoading().close()
        if (typeof res === 'string') {
          res = JSON.parse(res)
        }
        if ((res.code || res.code === 0) && res.code != 200) {
          this.handleError(res)
        } else {
          if (res.data.isSuccess === 0) {
              if (res.data.noticeList !== null) {
                  for (const item of res.data.noticeList.data) {
                      item['isPoperShow'] = false
                    }
                  that.noticeList = res.data.noticeList.data
                  that.serverPage.totalSize = res.data.noticeList.total
                }

              if (res.data.systemNoticeList !== null) {
                  for (const item of res.data.systemNoticeList.data) {
                      item['isPoperShow'] = false
                    }
                  that.systemNoticeList = res.data.systemNoticeList.data
                  that.sysServerPage.totalSize = res.data.sysNoticeTotal
                }
            } else if (res.data.isSuccess === 1) {
                _g.toastMsg('error', res.message)
              }
        }
      })
    },

        /* 删除公告 */
    deleteNotice(noticeId) {
      const that = this
      that.$confirm('是否确认删除?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
        center: true
      }).then(() => {
        _g.showLoading('删除中')
        that.apiPost('/admin/notice/delete', { noticeId }).then((res) => {
            _g.showLoading().close()
            if (typeof res === 'string') {
                res = JSON.parse(res)
              }
            if (res.code != 200) {
                that.handleError(res)
              } else {
                if (res.data.isSuccess === 0) {
                    _g.toastMsg('success', res.message)
                    that.getAllPagingNotice()
                  } else if (res.data.isSuccess === 1) {
                    _g.toastMsg('error', res.message)
                  } else if (res.data.isSuccess === 2) {
                      _g.toastMsg('warning', res.message)
                    }
              }
          })
      }).catch(() => {})
    },

        /* 审核公告 */
    examineNotice(noticeId, noticeReleaseRange) {
      this.currNoticeId = noticeId
      this.noticeReleaseRange = noticeReleaseRange
      this.isDialogVisible = true
    },
         /* 取消审核公告记录(实为重置为初始状态) */
    cancelExamineNotice() {
      this.isDialogVisible = false                                                //  审核弹框隐藏
      this.noticeAuditStatus = 2
      this.noticeAuditReason = ''
      this.currNoticeId = null//  当前待审核的公告id
      this.noticeReleaseRange = null//  当前待审核的公告id
    },

        /* 确认审核公告记录 */
    sureExamineNotice() {
      const that = this
      const noticeId = that.currNoticeId//  当前待审核的公告id
      const noticeAuditStatus = that.noticeAuditStatus//    审核结果，默认审核通过
      const noticeAuditReason = that.noticeAuditReason// ..审核原因
      const noticeReleaseRange = that.noticeReleaseRange

      const data = {
        noticeId,
        noticeAuditStatus,
        noticeAuditReason,
        noticeReleaseRange
      }

      if (noticeAuditStatus === 3 && noticeAuditReason === '') { // ..如果审核不通过，且没有填写审核原因
        return
      }

      _g.showLoading('提交中')

      that.apiPost('/admin/notice/examineNotice', data).then((res) => {
        _g.showLoading().close()
        if (typeof res === 'string') {
          res = JSON.parse(res)
        }
        if (res.code != 200) {
          that.handleError(res)
        } else {
          if (res.data.isSuccess === 0) {
              _g.toastMsg('success', res.message)
              that.getAllPagingNotice()

                        // 重置
              that.cancelExamineNotice()
            } else if (res.data.isSuccess === 1) {
            _g.toastMsg('error', res.message)
          } else if (res.data.isSuccess === 2) {
              _g.toastMsg('warning', res.message)
            }
        }
      })
    },

        // /* 发布公告 */
        // releaseNotice(index,noticeId){
        //     const that = this
        //     that.$confirm('是否确认发布?', '提示', {
        //         confirmButtonText: '确定',
        //         cancelButtonText: '取消',
        //         type: 'warning',
        //         center: true
        //     }).then(() => {
        //         _g.showLoading('发布中')
        //         that.apiPost('/admin/notice/release',{noticeId}).then((res) => {
        //         _g.showLoading().close()
        //         if(typeof res === 'string'){
        //                 res = JSON.parse(res)
        //             }
        //             if (res.code != 200) {
        //                 that.handleError(res)
        //             } else {
        //                 if(res.data.isSuccess === 0){
        //                     _g.toastMsg("success", res.message)
        //                     that.noticeList[index].is_release = 2

        //                     that.noticeList[index].notice_release_time = res.data.noticeReleaseTime

        //                 }else if(res.data.isSuccess === 1){
        //                     _g.toastMsg("error", res.message)
        //                 }else if(res.data.isSuccess === 2){
        //                     _g.toastMsg("warning", res.message)
        //                 }
        //             }
        //         })
        //     }).catch(() => {})
        // },

        /* 置顶公告 */
    roofNotice(noticeId) {
      const that = this
      that.$confirm('是否确认置顶?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
        center: true
      }).then(() => {
        _g.showLoading('提交中')
        that.apiPost('/admin/notice/roof', { noticeId }).then((res) => {
            _g.showLoading().close()
            if (typeof res === 'string') {
                res = JSON.parse(res)
              }
            if (res.code != 200) {
                that.handleError(res)
              } else {
                if (res.data.isSuccess === 0) {
                    _g.toastMsg('success', res.message)
                    that.getAllPagingNotice()
                  } else if (res.data.isSuccess === 1) {
                    _g.toastMsg('error', res.message)
                  } else if (res.data.isSuccess === 2) {
                      _g.toastMsg('warning', res.message)
                    }
              }
          })
      }).catch(() => {})
    },

        /* 取消置顶公告 */
    cancelRoofNotice(noticeId) {
      const that = this
      that.$confirm('是否确认取消置顶?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
        center: true
      }).then(() => {
        _g.showLoading('提交中')
        that.apiPost('/admin/notice/cancelRoof', { noticeId }).then((res) => {
            _g.showLoading().close()
            if (typeof res === 'string') {
                res = JSON.parse(res)
              }
            if (res.code != 200) {
                that.handleError(res)
              } else {
                if (res.data.isSuccess === 0) {
                    _g.toastMsg('success', res.message)
                    that.getAllPagingNotice()
                  } else if (res.data.isSuccess === 1) {
                    _g.toastMsg('error', res.message)
                  } else if (res.data.isSuccess === 2) {
                      _g.toastMsg('warning', res.message)
                    }
              }
          })
      }).catch(() => {})
    },

        /* 取消隐藏公告 */
    cancelHideReason() {
      this.isHideReasonDialogShow = false                                                //  弹框隐藏
      this.noticeHideReason = ''
      this.currHideNoticeId = null//  当前待隐藏的公告id
    },

        /* 显示隐藏公告弹框 */
    hideNotice(noticeId) {
      this.currHideNoticeId = noticeId
      this.isHideReasonDialogShow = true                                                //  显示隐藏公告弹框
    },

        /* 确认隐藏公告 */
    sureHideNotice() {
      const that = this
      const noticeId = that.currHideNoticeId
      const noticeHideReason = that.noticeHideReason
      if (noticeHideReason === '') {
        return
      }
      that.$confirm('是否确认隐藏?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
        center: true
      }).then(() => {
        _g.showLoading('提交中')
        that.apiPost('/admin/notice/hide', { noticeId, noticeHideReason }).then((res) => {
            _g.showLoading().close()
            if (typeof res === 'string') {
                res = JSON.parse(res)
              }
            if (res.code != 200) {
                that.handleError(res)
              } else {
                if (res.data.isSuccess === 0) {
                    _g.toastMsg('success', res.message)
                    that.getAllPagingNotice()
                    that.cancelHideReason()
                  } else if (res.data.isSuccess === 1) {
                    _g.toastMsg('error', res.message)
                  } else if (res.data.isSuccess === 2) {
                      _g.toastMsg('warning', res.message)
                      that.cancelHideReason()
                    }
              }
          })
      }).catch(() => {})
    },

        /* 显示公告 */
    ShowNotice(noticeId) {
      const that = this
      that.$confirm('是否确认显示?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
        center: true
      }).then(() => {
        _g.showLoading('提交中')
        that.apiPost('/admin/notice/cancelHide', { noticeId }).then((res) => {
            _g.showLoading().close()
            if (typeof res === 'string') {
                res = JSON.parse(res)
              }
            if (res.code != 200) {
                that.handleError(res)
              } else {
                if (res.data.isSuccess === 0) {
                    _g.toastMsg('success', res.message)
                    that.getAllPagingNotice()
                  } else if (res.data.isSuccess === 1) {
                    _g.toastMsg('error', res.message)
                  } else if (res.data.isSuccess === 2) {
                      _g.toastMsg('warning', res.message)
                    }
              }
          })
      }).catch(() => {})
    }
  },
  mixins: [http]
}
</script>

<style lang="less" scoped>
dl{
    cursor: pointer;
}
.noticeItemNav{
    color: black;
    font-size: 14px;
    line-height: 40px;
}
.otherInfo{
    font-size: 12px;
    color: #909399;
}
dl:hover .noticeItemNav{
    color: #ef8200 !important;
}


dl::after{
    content: "";
    display:block;
    border-bottom : 1px dotted #ccc;
    margin-top:20px;
}

</style>


